package com.yijumao.controller;

import com.yijumao.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.sql.Date;
import java.util.Arrays;
import java.util.List;

/**
 * @author konley
 * @date 2020-10-22 16:37
 */
@Controller
public class UserController {
    @GetMapping("/quick")
    public String quick(Model model){
        model.addAttribute("msg","平平无奇的thymeleaf获取参数");
        return "thymeleafTest";
    }

    @GetMapping("/foreach")
    public String foreach(Model model){
        List<User> users = Arrays.asList(
                new User("小明","20",new Date(System.currentTimeMillis())),
                new User("小军","21",new Date(System.currentTimeMillis())),
                new User("小华","22",new Date(System.currentTimeMillis()))
        );
        model.addAttribute("users",users);
        return "thymeleafTest";
    }
}
